package com.david.warehouse.mapper;

import com.david.warehouse.pojo.entity.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ProductMapper {
    @Insert("insert into whm_product (name,code,model,unit,remark,category_id,type_id) VALUES (#{name},#{code},#{model},#{unit},#{remark},#{categoryId},#{typeId})")
    void insertProduct(Product material);

    @Update("update whm_product set name=#{name},code=#{code},model=#{model},unit=#{unit},remark=#{remark},category_id=#{categoryId},type_id=#{typeId} where id=#{id}")
    void updateProduct(Product material);

    @Select("select id, name, code, model, type_id, category_id, unit, remark from whm_product where type_id = #{typeId} and category_id = #{categoryId}")
    List<Product> selectProductList(String categoryId, String typeId);

    @Delete("delete from whm_product where id=#{id}")
    void deleteProductById(Integer id);

    @Select("select id, name, code, model, type_id, category_id, unit, remark from whm_product where category_id = #{id}")
    List<Product> selectMaterialListByCategoryId(Integer id);
}
